from exts import db


class BasciInfoModel(db.Model):
    __tablename__ = 'basic_info'
    # id
    info_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    # 民族名称
    name = db.Column(db.String(30), nullable=False, unique=True)
    # 基本信息全解
    info = db.Column(db.Text, nullable=False)

    def to_dict(self, choice='user'):
        if choice == 'simple':
            return {c.name: getattr(self, c.name, None) for c in self.__table__.columns if c.name != 'info'}
        return {c.name: getattr(self, c.name, None) for c in self.__table__.columns}
